Fix a leak occurring at netif_map(). The problem raised after allocating
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Dec 2005 14:17:04 +0000 (15:17 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Dec 2005 14:17:04 +0000 (15:17 +0100)
both {rx,tx}_comms_area, and one (and just one) of them failed. As we
were
doing a single test for both, returning would leave one of them
allocated.

Signed-off-by: Glauber de Oliveira Costa <glommer@br.ibm.com>
linux-2.6-xen-sparse/drivers/xen/netback/interface.c

index c2641d99c9230429eac9759c48af57e78b18ab33..16cc929a111df40b21768dfe4f43efefd2ff371a 100644 (file)
@@ -196,9 +196,13 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref,
                return 0;
 
        netif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
+       if (netif->tx_comms_area == NULL)
+               return -ENOMEM;
        netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
-       if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL)
+       if (netif->rx_comms_area == NULL) {
+               free_vm_area(netif->tx_comms_area);
                return -ENOMEM;
+       }
 
        err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
        if (err) {